# -*- coding: UTF-8 -*- 
import pyodbc
import pprint
import random

conn = pyodbc.connect("DSN=ORACLE_SAMPLE;UID=qinyi365;PWD=qinyi365")
cursor = conn.cursor()
cursor.execute("select count(*) from TAB_EMPLOYEE;")
records = cursor.fetchall()
print "the count is %d",records[0]
cursor.execute("select * from TAB_EMPLOYEE;")
records = cursor.fetchall()
pprint.pprint(records)
username='001'
cursor.execute("select BAR_PASSWORD from TAB_EMPLOYEE where EMPLOYEE_CODE = ?",username)
records = cursor.fetchall()
pprint.pprint(records)



#cursor.execute("insert into TAB_CLASS values(?,?)",code_str,name_str)
#conn.commit()
cursor.execute("select * from TAB_CLASS")
records=cursor.fetchall()
pprint.pprint(records)
code_str="sohuds%d"%(len(records)+ 1)
name_str="insert for test %d"%(len(records))
print code_str
cursor.execute("insert into TAB_CLASS values (?,?)",code_str,name_str)
conn.commit()

